package vn.com.atm;


import android.app.TabActivity;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.TabHost;
import android.widget.TextView;
import android.widget.TabHost.TabSpec;

public class TabMain extends TabActivity{
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.tab_main);
		// buoc1: join tabhost
		TabHost tabs = (TabHost)findViewById(android.R.id.tabhost);
		// buoc2: dinh nghia tab
		 View tabView = createTabView(this, "Bản đồ");
		TabSpec tabmap = tabs.newTabSpec("Tabmap");
		Bundle bundle = getIntent().getExtras();
		
		String lat = bundle.getString("Lat");
		String longt = bundle.getString("Long");
		Intent iMap =new Intent(TabMain.this, MapViewActivity.class);
		iMap.putExtra("Lat", lat);
		iMap.putExtra("Long", longt);
		
		
		tabmap.setIndicator(tabView);
		tabmap.setContent(iMap);
		
		Intent iList =new Intent(TabMain.this, AtmDetail.class);
		
		
		iList.putExtra("Lat", lat);
		iList.putExtra("Long", longt);
		tabView = createTabView(this, "Danh sách");
		TabSpec tablist = tabs.newTabSpec("TabList");
		tablist.setIndicator(tabView);
		tablist.setContent(iList);
		// buoc 3 add tab
		tabs.addTab(tablist);
		tabs.addTab(tabmap);
		
	}
    private static View createTabView(Context context, String tabText) {
        View view = LayoutInflater.from(context).inflate(R.layout.custom_tab, null, false);
        TextView tv = (TextView) view.findViewById(R.id.tabTitleText);
        tv.setText(tabText);
        return view;
    }
}
